<?php
/**
 * 资金流水
 * User: liujb
 * Date: 2017/2/8
 * Time: 10:09
 */

namespace Api\Controller;


class CapitalflowController extends ApiController
{
    public function __construct(){
        parent::__construct();
        !api_login() && response(-94);
        !passed_login() && response(-95);
        !only_login() && response(-96);

    }

    /**
     * 查询资金流水
     *  stime 开始时间
     *  etime 结束时间
     */
      function getcapitalflow(){
        $fields = array('stime','etime');
        params_exist($fields);
        $stime = strtotime(I('stime'));
        $endtime =  I('etime');
        $etime =  strtotime("$endtime +23 hours 59 minute");
        $where['uid'] = API_UID;
        $where['cre_time'] = array(between,array($stime,$etime));
        $result = M('capital_flow')->where($where)->order('cre_time desc')->select();
        foreach ($result as &$re){
            $re['cre_time'] = date('Y-m-d', $re['cre_time']);
        }
        if (empty($result)) {
            response(-9,$result,'没有资金流水记录');
        }else{
            response(1, $result,'操作成功');
        }
    }
}